﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace SqlOrm.Xml
{
    public class Serializer
    {
        public static T DeSerialize<T>(string xml)
        {
            var serializer = new XmlSerializer(typeof(T));
            TextReader tr;
            using (tr = new StringReader(xml))
            {
               
                    return (T)serializer.Deserialize(tr);
                
       
            }
            return default(T);
        }
        public static string Serialize(object obj)
        {
            var serializer = new XmlSerializer(obj.GetType());
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            serializer.Serialize(sw, obj);
            return sb.ToString();
        }
    }
}
